package makefileGenerator;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.Properties;

import file.Texs;

public class MakeFileSource {
	public static MakeFileSource getMakeFileSource() {
		Properties Sysprops = System.getProperties();
		String osName = Sysprops.getProperty("os.name");
		if (osName.equals("Linux"))
			return new LinuxMakefileSource();
		else
			return new WindowsMakefileSource();
	}

	String deleteCMD;
	String htmlCMD;
	String pdfCMD;

	private List<File> texs;
	String indexCMD = "texdocletHtmlGenerator";

	public MakeFileSource() {
		readFromProperty();
		texs = Texs.getTexs().getTexList();
	}

	public List<File> getTexs() {
		return texs;
	}

	private Properties loadProperties() throws IOException {
		Properties properties;
		InputStream dbPropInputStream = null;
		dbPropInputStream = MakeFileSource.class
				.getResourceAsStream("cmds.properties");
		properties = new Properties();
		properties.load(dbPropInputStream);
		return properties;
	}

	private void readFromProperty() {
		try {
			Properties props = loadProperties();
			pdfCMD = (String) props.get("PDFCMD");
			htmlCMD = (String) props.get("HTMLCMD");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void setTexs(List<File> texs) {
		this.texs = texs;
	}

}
